import os
import random
import xml.etree.ElementTree as ET
from global_var import getPath
from utils.utils import get_classes

if __name__ == "__main__":
    xmlfilepath     = os.path.join(getPath(), 'Annotations')
    print("xmlfilepath:" + xmlfilepath)
    xmlfiles        = os.listdir(xmlfilepath)
    imgfilepath     = os.path.join(getPath(), 'JPEGImages')
    print("imgfilepath:" + imgfilepath)
    imgfiles        = os.listdir(imgfilepath)

    #查找文件
    for filename in xmlfiles:
        xmlfilename = os.path.splitext(filename)[0]
        imgfilename = xmlfilename+".jpg"
        if imgfilename not in imgfiles:
            xmlfile = xmlfilepath+"\\"+xmlfilename+".xml"
            if (os.path.exists(xmlfile)):
                os.remove(xmlfile)
                print("delete " + xmlfile)

        

    